layui.config({
    base: '/plugins/module/'
});

var id1 = null;
var id2 = null;
var id3 = null;

layui.use(['form', 'layer', 'laydate', 'table', 'laytpl', 'cstmodules', 'element', 'jquery','upload'], function () {
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery,
        laydate = layui.laydate,
        laytpl = layui.laytpl,
        table = layui.table,
        mymod = layui.cstmodules,
        element = layui.element,
        upload = layui.upload;

    var rankmgr={
        param:{
            tableColumn:[
                [
                    {type: 'checkbox'},
                    {field:'name',title:'姓名', align:'center'},
                    {field:'sex',title:'性别',align:'center',templet: function (d) {
                            // if (d.sex == "0") {
                            //     return '男';
                            // } else {
                            //     return '女';
                            // }
                          return d.sex == "0" ? '男':'女';
                        },
                       },
                    {field:'nativeplace',title:'籍贯',align:'center'},
                    {field:'major',title:'专业',align:'center'},
                    {field:'college',title:'学院',align:'center'},
                    {field:'score',title:'总分',align:'center'},
                    {field:'rank',title: '排名', align:'center',sort: true}
                ]
            ],
            mainIndex:null,
            url:null,
            limit:10,
            limits: [10, 30, 60, 120]
        },
        x:function () {
            
        },
    }

    form.on('select(college)', function(data){
        id1 = data.value;
        mymod.initSelectView(form,"/select/getMajorSelectList","major",id1,"请选择专业",null);
        mymod.initSelectView(form,"/select/getClassSelectList","class",null,"请选择班级",null);
    });

    form.on('select(major)', function(data){
        id2 = data.value;
        mymod.initSelectView(form,"/select/getClassSelectList","class",id2,"请选择班级",null);
    });

    form.on('select(class)', function(data){
        id3 = data.value;
    });

    mymod.initPageTableMethod(table,"scorerankinfo","/total/findAllUser",rankmgr.param.tableColumn,"#rankToolBar",null,rankmgr.param.limit,rankmgr.param.limits,170);

    mymod.initSelectView(form,"/select/getCollegeSelectList","college","null","请选择学院",null);



    //模糊查询
    form.on("submit(searchButton)",function(data){
        table.reload('scorerankinfo',{
            where:data.field,
            page:{
                curr:1
            }
        });
        return false;
    });

    //监听头部工具栏
    table.on('toolbar(menuTable)', function(obj){
        switch(obj.event){
            case 'add':
                sysmgr.openAddLayer();
                break;
            case 'batchdelte':
                sysmgr.batchDelete();
                break;
        };
    });

});